<?php

/**
 * This is the model class for table "booking_items".
 *
 * The followings are the available columns in table 'booking_items':
 * @property integer $item_id
 * @property integer $booking_id
 * @property string $danhxung
 * @property string $name
 * @property string $date_of_birth
 * @property integer $flight_code
 * @property string $flight_class
 * @property string $ticket_class
 * @property integer $baggage
 * @property integer $ticket_price
 * @property integer $tax_price
 * @property string $time1
 * @property string $time2
 * @property string $crypt
 */
class BookingItems extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'booking_items';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('booking_id, danhxung, name, date_of_birth, flight_code, flight_class, ticket_class, baggage, ticket_price, tax_price, time1, time2, crypt', 'required'),
			array('booking_id, flight_code, baggage, ticket_price, tax_price', 'numerical', 'integerOnly'=>true),
			array('danhxung, name, flight_class, ticket_class', 'length', 'max'=>50),
			array('crypt', 'length', 'max'=>200),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('item_id, booking_id, danhxung, name, date_of_birth, flight_code, flight_class, ticket_class, baggage, ticket_price, tax_price, time1, time2, crypt', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'item_id' => 'Item',
			'booking_id' => 'Booking',
			'danhxung' => 'Danhxung',
			'name' => 'Name',
			'date_of_birth' => 'Date Of Birth',
			'flight_code' => 'Flight Code',
			'flight_class' => 'Flight Class',
			'ticket_class' => 'Ticket Class',
			'baggage' => 'Baggage',
			'ticket_price' => 'Ticket Price',
			'tax_price' => 'Tax Price',
			'time1' => 'Time1',
			'time2' => 'Time2',
			'crypt' => 'Crypt',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('item_id',$this->item_id);
		$criteria->compare('booking_id',$this->booking_id);
		$criteria->compare('danhxung',$this->danhxung,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('date_of_birth',$this->date_of_birth,true);
		$criteria->compare('flight_code',$this->flight_code);
		$criteria->compare('flight_class',$this->flight_class,true);
		$criteria->compare('ticket_class',$this->ticket_class,true);
		$criteria->compare('baggage',$this->baggage);
		$criteria->compare('ticket_price',$this->ticket_price);
		$criteria->compare('tax_price',$this->tax_price);
		$criteria->compare('time1',$this->time1,true);
		$criteria->compare('time2',$this->time2,true);
		$criteria->compare('crypt',$this->crypt,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return BookingItems the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
